# -*- coding:utf-8 -*-

from core.curd import PageInfo, QueryWrapper


class IBaseService:
    """
  通用类
    select_by_id ( id )
    select_page( pageinfo, queryWarpper )
    select_options ( idField, nameField )
    insert(data)
    update(data)
    delete_by_id(id)
    delete_batch_ids(ids)

  """

    async def select_by_id(self, id):
        return await self.dao.select_by_id(id)

    async def select_page(self, page: PageInfo, where: dict, resultHandler=None):
        return await self.dao.select_page(page, where)

    async def select_count(self, queryWraper: QueryWrapper):
        pass

    async def insert(self, entity, last_id: bool = False):
        return await self.dao.insert(entity, last_id)

    async def update(self, entity):
        return await self.dao.update(entity)

    async def delete_by_id(self, id):
        return await self.dao.delete_by_id(id)

    async def delete_batch_ids(self, ids):
        return await self.dao.delete_batch_ids(ids)

    async def delete(self, queryWraper: QueryWrapper):
        pass

    async def select_options(self):
        return await self.dao.select_options();